﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SalesModel;

namespace SalesController.ClassesDB
{
    [Serializable]
    public class ProductsDB
    {
        DAOFactory daoFactory = null;
        DAOProduct daoProduct = null;

        public ProductsDB()
        {
            daoFactory = DAOFactory.getDAOFactory(DBConnection.dbType);
            daoProduct = daoFactory.getDAOProduct(); //Polimorfismo
        }

        public List<Product> Values
        {
            get { return daoProduct.queryAll(); }
        }
        public void Add(Product p)
        {
            //productList.Add(p);
            daoProduct.add(p);
        }
        public int Size
        {
            get { return daoProduct.count(); }
        }
        public void Delete(int i)
        {
            //productList.RemoveAt(i);
            daoProduct.delete(i);
        }
        public void Update(Product p)
        {
            daoProduct.update(p);
        }
        public Product QueryById(int productId)
        {
            return daoProduct.queryById(productId);
        }
    }
}
